package tech.aistar.day06.apps;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletContextController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String path=req.getPathInfo();
        ServletContext application=req.getServletContext();
        switch (path){
            case "/set":
                application.setAttribute("app","admin");
                break;
            case "/get":
                String app= (String) application.getAttribute("app");
                System.out.println(app);
                break;
        }
    }
}
